package com.hl.ruoyicsmshop.controller;

import com.hl.ruoyicsmshop.service.IProductStatisticsService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/product")
public class ProductStatisticsController {

    @Autowired
    private IProductStatisticsService productStatisticsService;

    /**
     * 查询商品统计数据
     */
    @GetMapping("/statistics")
    public R<List<Map<String, Object>>> getProductStatistics(
            @RequestParam(value = "timeRange", required = false) String timeRange,
            @RequestParam(value = "monthYear", required = false) List<String> monthYear,
            @RequestParam(value = "tab", required = false) String tab) {
        List<Map<String, Object>> result = productStatisticsService.getProductStatistics(timeRange, monthYear, tab);
        return R.ok(result);
    }
}